<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="/layout/template.xhtml">


	<ui:define name="body">


		<a4j:form id="servicoStatusForm">
			<p:messages globalOnly="true" styleClass="message" />
			<rich:simpleTogglePanel switchType="client">
				<f:facet name="header">Status Serviço</f:facet>
				<div style="clear: both" />

				

					<s:decorate id="descricaoField" template="/layout/edit.xhtml">
						<ui:define name="label">Descricao:</ui:define>
						<h:inputText id="descricao" size="60"
							value="#{servicoStatus.descricao}" required="true">
							<a4j:support event="onblur" reRender="descricaoField"
								bypassUpdates="true" ajaxSingle="true"  status="none"/>
						</h:inputText>
					</s:decorate>
					
					
				<br />
				<br />
				<div style="clear: both"><span class="required">*</span>
				Campos requeridos</div>

				<div style="clear: both" />
				<br />
				<br />
				<div class="actionButtons">
				<a4j:commandButton value="Inserir"
					style=" width : 100px;" action="#{servicoStatusAction.salvar(servicoStatus)}"
					rendered="#{servicoStatus.id == null}"
					reRender="servicoStatusForm, frmTabelaServicoStatus" /> 
				<a4j:commandButton
					value="Editar" style=" width : 100px;"
					action="#{servicoStatusAction.alterar(servicoStatus)}"
					rendered="#{servicoStatus.id != null}"
					reRender="servicoStatusForm, frmTabelaServicoStatus" /> 
				<a4j:commandButton
					value="#{messages['btnCancel']}" style="width : 100px;"
					action="#{servicoStatusAction.cancelar()}"
					rendered="#{servicoStatus.id != null}" reRender="servicoStatusForm"
					ajaxSingle="true" /></div>


				

			</rich:simpleTogglePanel>
		</a4j:form>
		
		<rich:spacer width="5px" />
		<br />
		<br />
		
		<a4j:form id="frmTabelaServicoStatus"
			rendered="#{!identity.hasRole('tecnico')}">

			<rich:dataTable value="#{servicoStatusAction.carregarTodos()}"
				var="servicoStatus" rows="10" reRender="ds" id="simpletable"
				rendered="#{servicoStatusAction.carregarTodos().size > 0}"
				columnClasses="center"
				onRowMouseOver="this.style.backgroundColor='#b2d5d6'"
				onRowMouseOut="this.style.backgroundColor='#FFFFFF'">
				<f:facet name="header">
					<h:outputText value="Status Serviço" />
				</f:facet>
				<rich:column sortBy="#{servicoStatus.descricao}">
					<f:facet name="header">
						<h:outputText value="Descrição" />
					</f:facet>
					<h:outputText value="#{servicoStatus.descricao}" />
				</rich:column>
				
				<rich:column style="text-align: center;" rendered="#{identity.hasRole('admin')}">
					<f:facet name="header">
						<h:outputText value="Editar" />
					</f:facet>
					<a4j:commandLink
						action="#{servicoStatusAction.selecionarServicoStatus(servicoStatus)}"
						reRender="servicoStatusForm">
						<h:graphicImage value="/img/ico_altera_16.gif"
							style="border: none;" alt="Alterar" title="Alterar Registro" />
					</a4j:commandLink>
				</rich:column>
				<rich:column style="text-align: center;" rendered="#{identity.hasRole('admin')}">
					<f:facet name="header">
						<h:outputText value="Apagar" />
					</f:facet>
					<a4j:commandLink action="#{servicoStatusAction.excluir(servicoStatus)}"
						reRender="simpletable"
						onclick="if(!confirm('Confirma Exclus&#227;o?')){return false;}">
						<h:graphicImage value="/img/ico_apaga_16.gif"
							style="border: none;" alt="Excluir" title="Excluir Registro" />
					</a4j:commandLink>
				</rich:column>


				<f:facet name="footer">
					<rich:datascroller id="ds"></rich:datascroller>
				</f:facet>
			</rich:dataTable>


			<s:fragment rendered="#{servicoStatusAction.carregarTodos().size > 0}">
				<h:outputText
					value="Total de Registros: #{servicoStatusAction.carregarTodos().size}" />
			</s:fragment>

		</a4j:form>



	</ui:define>

</ui:composition>

